{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "importing-libraries",
   "metadata": {},
   "source": [
    "## Importing Libraries\n",
    "\n",
    "First, we import the necessary library for data manipulation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "code-import",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "explanation-import",
   "metadata": {},
   "source": [
    "We import the `pandas` library, which is essential for working with data structures like DataFrames."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "downloading-data",
   "metadata": {},
   "source": [
    "## Loading S&P500 Futures Data\n",
    "\n",
    "Next, we load the S&P500 futures price data from a CSV file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "code-read-data",
   "metadata": {},
   "outputs": [],
   "source": [
    "sp500_prices = pd.read_csv(\"../data/sp500.csv\", index_col=0, parse_dates=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "explanation-read-data",
   "metadata": {},
   "source": [
    "We use `pd.read_csv()` to load the data from a CSV file called `sp500.csv`. The `index_col=0` sets the first column as the index, and `parse_dates=True` ensures that the index is interpreted as dates, which is crucial for time series data."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "calculate-log-returns",
   "metadata": {},
   "source": [
    "## Calculating Daily Returns\n",
    "\n",
    "Next, we calculate the daily percentage changes in the futures prices."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "code-log-returns",
   "metadata": {},
   "outputs": [],
   "source": [
    "returns = None  # YOUR CODE HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "annualized-mean-return",
   "metadata": {},
   "source": [
    "## Annualizing the Mean Return\n",
    "\n",
    "We then compute the annualized mean return using the daily returns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "code-annualized-mean",
   "metadata": {},
   "outputs": [],
   "source": [
    "annualized_mean_return = None  # YOUR CODE HERE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2eb37878",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(f\"Annualized Mean Return: {annualized_mean_return[0]:.2%}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "explanation-annualized-mean",
   "metadata": {},
   "source": [
    "We take the mean of the daily returns and multiply it by 252, which is the approximate number of trading days in a year. This gives us the annualized mean return, which is printed as a percentage."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
